'''
Created on Feb 22, 2010

@author: mkiyer
'''

from veggie.db.phdb.phdb import PileupDB

if __name__ == '__main__':
    import sys
    
    infile = sys.argv[1]
    db_file = sys.argv[2]
    sdbi_path = sys.argv[3]
    
    phdb = PileupDB(db_file, 'r', sdbi_path)
        
    for line in open(infile):
        library_id = line.strip().split()[0]

        if ('/' + library_id) in phdb.h5file:
            n = phdb.h5file.getNode('/' + library_id) 
            nreads = n._v_attrs.reads
            print '\t'.join([line.strip(), str(nreads)]) 
